package com.rm.zeyou.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import com.rm.zeyou.entity.Technician;
import com.rm.zeyou.response.ApiRestResponse;
import com.rm.zeyou.service.TechnicianSosService;
import com.rm.zeyou.util.login.TechnicianLoginUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.io.IOException;

/**
 * <p>
 * 技师求救表 前端控制器
 * </p>
 *
 * @author YanYang
 * @since 2025-04-19 13:44:40
 */
@Api(tags = "技师求救相关")
@RestController
@RequestMapping("/api/technicianSos")
public class TechnicianSosController {
    @Resource
    private TechnicianSosService technicianSosService;
    @Resource
    private TechnicianLoginUtil technicianLoginUtil;

    @ApiOperation(value = "技师求救")
    @GetMapping("technicianSos")
    @SaCheckLogin(type = "technician")
    public ApiRestResponse<Integer> technicianSos() throws IOException {
        Technician technician = technicianLoginUtil.getTechnician();
        return technicianSosService.technicianSos(technician);
    }


    @ApiOperation(value = "技师求救上传录音")
    @GetMapping("technicianSosUploadVoice")
    @SaCheckLogin(type = "technician")
    public ApiRestResponse<Integer> technicianSosUploadVoice(@RequestParam String voiceUrl) {
        Technician technician = technicianLoginUtil.getTechnician();
        return technicianSosService.technicianSosUploadVoice(technician,voiceUrl);
    }
}
